<%@ page contentType="text/html; charset=UTF-8" pageEncoding="utf-8"%>
<!-- 回购 -->
<%@ include file="/common/init.jsp"%>
<script src="<c:url value='/resources/js/jquery-1.7.2.min.js"'/>"></script>
<link href="<c:url value='/admin/css/custom.css'/>" rel="stylesheet" type="text/css" />
<link href="<c:url value='/admin/css/style.css'/>" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<c:url value='/resources/js/jquery-1.7.2.min.js'/>"></script>
<script type="text/javascript" src="<c:url value='/resources/js/mask.js'/>"></script>
<script type="text/javascript" src="<c:url value='/resources/My97DatePicker/WdatePicker.js'/>"></script>
<div class="EpmsSubTitle"><p><b>股票买卖（回购）</b></p></div>
<form method="post" action="callback.action?cmd=search" id="stockSBForm">
	<table width="100%" border="0" cellspacing="0" cellpadding="0" class="EpmsTable">
		<tr>
			<td class=EpmsTdTitle >股票类型：</td>
		    <td class=EpmsTdNoColor >
		    	<select style="width:200px;" name="stockType" id="stockType">
		    		<option value="C" <c:if test="${stockType == 'C' }">selected</c:if>>C（9月29日前用户）</option>
		    		<option value="D" <c:if test="${stockType == 'D' }">selected</c:if>>D（9月29日-12月2日）</option>
		    		<option value="E" <c:if test="${stockType == 'E' }">selected</c:if>>E（12月2日-12月16日）</option>
		    		<option value="F" <c:if test="${stockType == 'F' }">selected</c:if>>F（12月16日-3月10日）</option>
		    	</select>&nbsp;&nbsp;&nbsp;&nbsp;
		    	<input type="submit" value="搜索"/> &nbsp;&nbsp; | &nbsp;&nbsp;
		    	售出比例：<input type="text" value="" name="per" style="width:50px;"/>
		    	<input type="button" value="确认售出" id="stockSale1"/> 
		    </td>
		</tr>
	</table>
</form>
<div class="EpmsSubTitle"><p><b>数据列表</b></p>
</div>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="EpmsTable">
  <tr>
	  <td class=EpmsTdTitle>
	<input type="checkbox" id="checkAll" onclick="checkAll();"/>全选 
	  </td>
	  <td class=EpmsTdTitle>类型</td>
	  <td class=EpmsTdTitle>用户名</td>
	  <td class=EpmsTdTitle>剩余股数</td>
	  
  </tr>
  	<c:set var="sum" value="0"/>
	<c:forEach var="stock" items="${stockList }" varStatus="index">
		<tr>
		    <td class=EpmsTdNoColor ><input type="checkbox" name="userx" value="${stock.userId }"></td>
		    <td class=EpmsTdNoColor >${stock.stockType}</td>
			<td class=EpmsTdNoColor >${stock.userId }</td>
			<td class=EpmsTdNoColor >${stock.stockNum }</td>
			<c:set var="sum" value="${sum+stock.stockNum }"/>
		</tr>
	</c:forEach>
	<tr>
	  <td class=EpmsTdNoColor>股票数合计</td>
	  <td class=EpmsTdNoColor>${sum }</td>
  </tr>
</table>
<script>
	$("#stockSale1").click(function(){
		var userx = $("input[name=userx]").filter(":checked");
		if(userx.size() == 0){
			alert("请选择用户后操作。");
			return;
		}
		var userids = "";
		userx.each(function(){
			userids = userids + "," + $(this).val();
		});
		
		if(window.confirm("确认进行此操作吗？")){
			$('#stockSale1').attr("disabled", true); 
			var form = $("#stockSBForm");
			form.attr("action","callback.action?cmd=callback&userids="+userids);
			form[0].submit();
		}
	});
	
	//全选
	function checkAll(){
		/* var checked=$("#select_all").attr("checked");
		$("input[name='chkIct'][type='checkbox']").each(function (){
			if(checked){
				$(this).attr("checked","checked");
			}else{
				$(this).removeAttr("checked");
			}
		}); */
		
		var c_checked=$("input[name='userx'][type='checkbox']:checked");
		var c_checkbox=$("input[name='userx'][type=checkbox]");
		if(c_checked.size()!=c_checkbox.size()){
			for(var i=0;i<c_checkbox.size();i++){
				c_checkbox[i].checked=true;
			}
		}else{
			for(var i=0;i<c_checkbox.size();i++){
				c_checkbox[i].checked=false;
			}
		}
		
		/* var text = this.value;
		if(text === "全选"){
			this.value = "全不选";
			$("input[name='chkIct'][type='checkbox']").attr("checked",true);
		}else{
			this.value = "全选";
			$("input[name='chkIct'][type='checkbox']").attr("checked",false);
		} */
	}
</script>